#ifndef LOGGER_H
#define LOGGER_H
#include <QString>
#include <QList>
#include <QThread>
#include <QMutexLocker>
#include "ccreader.h"

namespace Logg
{
enum LogTypes
{
    LERROR=0,
    LINFO,
    LSYS,
    LALERT,
    LDEBUG,
    IDEBUG,
    ODEBUG,
    IDEBUD,
    ODEBUD
};
struct LogItem
{
    QString text;
    LogTypes type;
};
enum ColorTypes
{
    BLACK,
    RED,
    GREEN,
    BROWN,
    BLUE,
    MAGENTA,
    CYAN,
    GREY,
    YELLOW,
    LRED,
    LGREEN,
    LBLUE,
    LMAGENTA,
    LCYAN,
    WHITE
};
const quint8 MaxColors = quint8(WHITE) + 1;

class Logger : public QThread
{
    Q_OBJECT
public:
    Logger(QObject *parent = 0);
    ~Logger(){ILoop=false;}

    void run();
    void LogIt(QString text, LogTypes type=LINFO);
    void bye(){ILoop=false;}
private:
    QString LogStr[9];
    QList<LogItem> logs;
    bool ILoop;

    void ShowLog(LogItem);
    void SetColor(ColorTypes color);
    void ResetColor(bool stdout_stream);
    mutable QMutex mutex;
    CCReader* cre;
};

}
#endif // LOGGER_H
